﻿<%@ Page Language="C#" AutoEventWireup="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
    <title>Sistem Informasi Penerimaan OJK - Home</title>
    <link rel="stylesheet" href="styles/blitzer/jquery-ui-1.9.2.custom.min.css" type="text/css" />
    <link rel="stylesheet" href="styles/home.css" type="text/css" />
    <link rel="stylesheet" href="styles/button.css" type="text/css" />
    <link rel="stylesheet" href="styles/CustomJquery.css" type="text/css" />
    <link href="styles/jquery.realperson.css" rel="stylesheet" type="text/css" />
    <script src="scripts/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="scripts/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
    <script src="scripts/jquery.sha1.js" type="text/javascript"></script>
    <script src="scripts/jquery.realperson.min.js" type="text/javascript"></script>


    <script type="text/javascript">

        // Set timeout captcha.
        var timoutNow = 300000; // Timeout in 5 minutes

        var timeoutTimer;

        // Start timers.
        function StartTimers() {
            timeoutTimer = setTimeout("IdleTimeout();", timoutNow);
        }

        // Reset timers.
        function ResetTimers() {
            clearTimeout(timeoutTimer);
            StartTimers();
        }

        function IdleTimeout() {
            $('#txtExpire').val('1');
        }

        function RefreshCaptcha() {

            $('#txtCaptcha').realperson('destroy');
            $('#txtCaptcha').realperson({
                regenerate: 'Klik untuk mengubah',
                length: 5,
                includeNumbers: true
            });
            $('#txtCaptcha').val('');
            $('#txtCaptcha').focus();
            $('#txtExpire').val('0');
            ResetTimers();

        }
    
    </script>

    <script type="text/javascript">

        $(document).ready(function () {
            //$('#txtExpire').val('0');
            $.fn.extend({
                // Converts with every keystroke the hole text to uppercase
                upperCase: function () {
                    $(this).keyup(function (event) {
                        var box = event.target;
                        var txt = $(this).val();
                        var start = box.selectionStart;
                        var end = box.selectionEnd;

                        $(this).val(txt.toUpperCase());
                        box.setSelectionRange(start, end);
                    });
                    return this;
                }
            });

            //input captcha harus huruf besar semua
            $('#txtCaptcha').upperCase();

            $('#txtCaptcha').realperson({
                regenerate: 'Klik untuk mengubah',
                length: 5,
                includeNumbers: true
            });

            $("#dialog-confirm").dialog({
                autoOpen: false,
                resizable: false,
                height: 290,
                width: 590,
                modal: true,
                buttons: {
                    Ya: function () {
                        $('#dialog1').load('forms/transaction/recRegistrationDebtorAfterform.aspx').dialog({
                            autoOpen: false, modal: true, width: 800, title: 'Registrasi', position: ['center', 0],
                            close: function (event, ui) {
                                $('#dialog1').empty().dialog('destroy');
                            }
                        });
                        $('#dialog-confirm').dialog('close');
                        $("#dialog1").dialog('open');
                    },
                    Tidak: function () {
                        $('#dialog1').load('forms/transaction/recRegistrationform.aspx').dialog({
                            autoOpen: false, modal: true, width: 900, title: 'Registrasi', position: ['center', 0],
                            close: function (event, ui) {
                                $('#dialog1').empty().dialog('destroy');
                            }
                        });
                        $('#dialog-confirm').dialog('close');
                        $("#dialog1").dialog('open');
                    }
                }
            });

            $('#btnRegistrasi').click(function () {

                $("#dialog-confirm").dialog('open');
                $("#dialog-confirm").html('<center><span style="font-weight:bold;font-size:small;"><br/><br/><br/><br/>Apakah sudah memperoleh perizinan/persetujuan/pendaftaran/pengesahan di OJK sebelum  tahun 2013?</span></center>');

                return false;

            });

            $('#btnAksiKorporasi').click(function () {

                $('#dialog1').load('forms/transaction/recCorporateActionform.aspx').dialog({
                    autoOpen: false, modal: true, width: 800, title: 'Aksi Korporasi', position: ['center', 0],
                    close: function (event, ui) {
                        $('#dialog1').empty().dialog('destroy');
                    }
                });

                $("#dialog1").dialog('open');

                return false;

            });
            $('#hrfForgotPassword').click(function () {
                var formUrl = '<%= ResolveUrl("~/forms/authentication/forgotpassword.aspx") %>';

                $('#dialog1').load(formUrl).dialog({
                    autoOpen: false, modal: true, width: 450, title: 'Lupa Password',
                    close: function (event, ui) {
                        $('#dialog1').empty().dialog('destroy');
                    }
                });

                $("#dialog1").dialog('open');

                return false;

            });


            $('#btnMasuk').click(function () {

                var kode = $('#txtKode').val();
                var pwd = $('#txtPassword').val();
                var captchaHash = $("input[name='txtCaptchaHash']").val();
                var captcha = $("#txtCaptcha").val();
                var expire = $("#txtExpire").val();

                var isPersistent = $('#cbIsPersistent').is(":checked");

                if (captcha == '') {

                    alert('Captcha harus di isi!');
                    RefreshCaptcha();

                    return false;
                }

                var objUser = new Object();
                objUser.UserCode = encodeURIComponent(kode);
                objUser.IsPersistent = isPersistent;
                objUser.CaptchaHash = captchaHash;
                objUser.Captcha = captcha;
                objUser.IsExpired = expire;

                if (typeof ($('#txtPassword').val()) != 'undefined')
                    objUser.Password = encodeURIComponent($.sha1($('#txtPassword').val()));

                jsonData = JSON.stringify(objUser);

                $.ajax({
                    type: 'POST',
                    url: 'ajaxhandler/authentication/loginhandler.ashx',
                    contentType: 'application/json',
                    dataType: 'json',
                    data: jsonData,
                    success: function (data) {

                        if (data.IsValid == 'True') {

                            window.location = data.DefaultUrl;

                        }
                        else {

                            alert(data.Message);
                            RefreshCaptcha();
                        }

                    },
                    error: function (response) {
                        var r = JSON.parse(response.responseText);
                        alert("Error Message: " + r.Message);

                    }
                });

                return false;

            });

        });

    </script>
</head>
<body onload="StartTimers();" onmousemove="ResetTimers();" onkeydown="ResetTimers();">
    <form id="frmLogin" method="post" action="">
    <div class="container">
        <div class="content">
            <div class="fltlft leftku">
                <div class="logo_index">
                    <img src="images/logo_FB.png" width="230" alt="OJK" />
                </div>
                <div class="nama_aplikasi">
                </div>
            </div>
            <div class="loginku">
                <table width="650" height="50" border="0" cellspacing="5" cellpadding="0" class="form_login">
                    <tr>
                        <td width="100">
                            <b>Kode User :</b>
                        </td>
                        <td>
                            <input type="text" size="25" class="inputTxt" id="txtKode" name="txtKode" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Sandi :</b>
                        </td>
                        <td>
                            <input type="password" size="25" class="inputTxt" id="txtPassword" name="txtPassword" />
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <div class="captchaLogin">
                                <div class="headCaptcha">
                                    CAPTCHA</div>
                                <div class="imageCaptcha">
                                    <input type="text" id="txtCaptcha" name="txtCaptcha" class="inputTxt" maxlength="5"
                                        style="width: 54px !important; text-align: center;" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <input id="cbIsPersistent" name="cbIsPersistent" type="checkbox" value="" />Biarkan
                            saya tetap masuk
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <a href="#" id="hrfForgotPassword">Lupa kata sandi anda?</a>
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <input name="btnMasuk" id="btnMasuk" type="submit" value="Masuk" class="button" />
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
                <!--end login-->
            </div>
           
            <div class="footer">
                2014 &copy; Hak Cipta dimiliki PT.Fastrata Buana
                <!-- end .footer -->
            </div>
        </div>
        <!-- end .content -->
    </div>
    <!-- end .container -->
    <input type="hidden" id="txtExpire" value="0" />
    <div id="dialog1" title="Default dialog">        
    </div>
    <div id="dialog-confirm" title="Konfirmasi">
    </div>
    </form>
</body>
</html>
